﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web_Oto.Business;
using Web_Oto.Common;

namespace Web_Oto.UC
{
    public partial class TopNews : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
                GetTopNews();
        }

        private void GetTopNews()
        {
            var showItem = int.Parse(ConfigurationManager.AppSettings["showTopNews"]);
            var newsBus = new NewsBus();
            var listNews = newsBus.GetTopNews(showItem, null);
            var sb = new StringBuilder();
            foreach (var listNew in listNews)
            {
                sb.AppendFormat("<li><a href='/tin-tuc/{0}/{1}.html'>{2}</a></li>", CommonHelper.NiceUrl(listNew.Name),listNew.Id, listNew.Name);
            }
            ltrNewsList.Text = sb.ToString();
        }
    }
}